package top.csjss.hospital.handler;

import org.apache.shiro.authc.IncorrectCredentialsException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import top.csjss.hospital.enums.HospitalExceptionEnums;
import top.csjss.hospital.exception.HospitalException;
import top.csjss.hospital.vo.R;

/**
 * @Author ztf
 * @Date 19:36 2021/10/15
 * 异常处理器
 **/
@RestControllerAdvice
public class HospitalExceptionHandler {
    @ExceptionHandler({IncorrectCredentialsException.class,UnknownError.class})
    public R credentialsException(){
        return R.error(HospitalExceptionEnums.USERNAME_PASSWORD_ERROR,"密码错误");
    }
    @ExceptionHandler({HospitalException.class})
    public R hospitalException(HospitalException hospitalException){
        return R.error(hospitalException.getCode(), hospitalException.getMessage());
    }
}
